import 'package:flutter/material.dart';
import 'package:flutter_application_cyber/net/cn_net_helper.dart';
import 'package:flutter_application_cyber/model/cn_net_response.dart';
import 'package:flutter_application_cyber/model/cn_user_default_cache.dart';
import 'package:provider/provider.dart';
import 'package:flutter_application_cyber/model/cn_anchor_model.dart';
import 'package:flutter_util_code/toast_utils.dart';
import 'dart:async';

class CnCallWaitPage extends StatefulWidget {
  final String nikeName;
  final String avatarUrl;

  const CnCallWaitPage(
      {Key? key, required this.nikeName, required this.avatarUrl})
      : super(key: key);

  @override
  State<CnCallWaitPage> createState() => _CnCallWaitPageState();
}

class _CnCallWaitPageState extends State<CnCallWaitPage> {
  Timer? timer1;
  Timer? timer2;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    timer1 = Timer(const Duration(seconds: 7), () {
      ToastUtils.show('The users mobile phone is not around');
      timer2 = Timer(const Duration(seconds: 2), () {
        Navigator.of(context).pop();
      });
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    timer1?.cancel();
    timer2?.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Container(
      width: double.infinity,
      decoration: BoxDecoration(
        image: DecorationImage(
            image: AssetImage('images/icon_page_bg_1.png'), fit: BoxFit.fill),
      ),
      child: Column(children: [
        Container(
          margin: const EdgeInsets.only(top: 150),
          width: 128,
          height: 128,
          clipBehavior: Clip.hardEdge,
          decoration: BoxDecoration(borderRadius: BorderRadius.circular(64)),
          child: Image.network(widget.avatarUrl),
        ),
        Container(
          margin: const EdgeInsets.only(top: 25, left: 30, right: 30),
          child: Text(
            widget.nikeName,
            style: TextStyle(
              color: Color(0xFFFFFFFF),
              fontSize: 18,
            ),
          ),
        ),
        InkWell(
          onTap: () {
            Navigator.of(context).pop();
          },
          child: Container(
            margin: EdgeInsets.only(top: 138),
            width: 78,
            height: 78,
            child: Image.asset('images/call_wait_btn.png'),
          ),
        )
      ]),
    ));
  }
}
